<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" style="display: flex; flex-wrap: nowrap;" :inline="true"
      v-show="showSearch" label-width="68px">
      <el-form-item label="充值公司" prop="f0302" style="display: flex; flex-wrap: nowrap;">
        <el-select v-model="queryParams.f0301" placeholder="请选择充值公司" clearable style="width: 14vw;">
          <el-option v-for="item in companys" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="充值时间">
        <el-date-picker @change="handleDateChange" v-model="daterangeF1003" style="width: 240px"
          value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期"
          end-placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item style="margin: 0 0 0 30vw;">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row> -->

    <el-table v-loading="loading" :data="YYDRechargeHistoryList">
      <el-table-column label="充值公司" align="center" prop="f1008" />
      <el-table-column label="充值人" align="center" prop="f1007">
        <!-- <template slot-scope="scope">
          <span v-if="scope.row.f1006 === 1 && scope.row.f0602">{{ scope.row.f0602 }}</span>
          <span v-else>{{scope.row.f0302}}</span>
        </template> -->
      </el-table-column>
      <el-table-column label="充值金额" align="center" prop="f1002" />
      <el-table-column label="充值时间" align="center" prop="f1003" width="180"/>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { listYYDRechargeHistory} from "@/api/YYDRechargeHistory/YYDRechargeHistory";
import { listT03 } from "@/api/t03/t03";
export default {
  name: "YYDRechargeHistory",
  dicts: ['deposit_method', 'deposit_object'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 充值记录表格数据
      YYDRechargeHistoryList: [],
      // 账户余额时间范围
      daterangeF1003: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        f1003: null,
        f1006: null,
        f0301: null,
        startDate: null,
        endDate: null
      },
      companys:[], // 公司列表
    };
  },
  created() {
    this.getList();
    listT03().then(res => {
      res.rows.forEach(item => {
        this.companys.push({ label: item.f0302, value: item.f0301 })
      })
    })
  },
  methods: {
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeF1003 && '' != this.daterangeF1003) {
        this.queryParams.startDate = this.daterangeF1003[0];
        this.queryParams.endDate = this.daterangeF1003[1];
      }
      listYYDRechargeHistory(this.queryParams).then(response => {
        this.YYDRechargeHistoryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeF1003 = '';
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        f1003: null,
        f1006: null,
        f0301: null,
        startDate: null,
        endDate: null
      },
      this.handleQuery();
    },

    // 时间选择器变化
    handleDateChange(value) {
      if (!value || value.length === 0) {
        this.queryParams.startDate = null;
        this.queryParams.endDate = null;
      } else {
        this.queryParams.startDate = value[0];
        this.queryParams.endDate = value[1];
      }
    },
  }
};
</script>
